function update_caption(fig)

    global used_energy;
    global iterations;
    global hEdit2;
    global hEdit3;
    global hEdit4;
    global h2Edit2;
    global h2Edit3;
    global h2Edit4;
    
    edit2 = used_energy;
    edit3 = iterations;
    edit4 = avg_msg_energy();
    
    if (fig == 1) 
        set(hEdit2,'String',edit2);
        set(hEdit3,'String',edit3);
        set(hEdit4,'String',edit4);
    else       
        set(h2Edit2,'String',edit2);
        set(h2Edit3,'String',edit3);
        set(h2Edit4,'String',edit4);
    end

end

